<template>
  <!-- 此页面是接待人填写基本信息 -->
  <div class="JNPF-common-layout" style="min-height: 600px;">
    <div class="JNPF-preview-main">
      <div class="JNPF-common-page-header">
        <div class="options">

          <el-button type="primary" @click="dataFormSubmit()"> 保 存</el-button>
          <el-button @click="resetForm">重置</el-button>
          <el-button @click="goBack">关闭</el-button>
        </div>
      </div>
      <el-row :gutter="15" class=" main" :style="{margin: '0 auto',width: '100%'}">
        <el-form ref="elForm" :model="dataForm" :rules="rules" size="small" label-width="140px" label-position="right">
          <template v-if="!loading">
            <!-- <el-col :span="12">
              <el-row :gutter="15">
                <el-col :span="24">
                  <el-form-item label="拜访编码" prop="visitnum">
                    <el-input v-model="dataForm.visitnum" placeholder="请输入" clearable :style='{"width":"100%"}'>

                    </el-input>
                  </el-form-item>
                </el-col>
              </el-row>
            </el-col> -->
            <el-col :span="12">
              <el-row :gutter="15">
                <el-col :span="24">
                  <el-form-item label="来访单位" prop="lfcompant">
                    <el-input v-model="dataForm.lfcompant" placeholder="请输入" clearable :style='{"width":"100%"}'>

                    </el-input>
                  </el-form-item>
                </el-col>
              </el-row>
            </el-col>
            <el-col :span="24">
              <el-row :gutter="15">
                <el-col :span="24">
                  <el-form-item label="来访事由" prop="lfreason">
                    <el-input v-model="dataForm.lfreason" placeholder="请输入" clearable :style='{"width":"100%"}'>

                    </el-input>
                  </el-form-item>
                </el-col>
              </el-row>
            </el-col>
            <el-col :span="12">
              <el-row :gutter="15">
                <el-col :span="24">
                  <el-form-item label="来访联系人姓名" prop="lfperson">
                    <el-input v-model="dataForm.lfperson" placeholder="请输入" clearable :style='{"width":"100%"}'>

                    </el-input>
                  </el-form-item>
                </el-col>
              </el-row>
            </el-col>
            <el-col :span="12">
              <el-row :gutter="15">
                <el-col :span="24">
                  <el-form-item label="来访联系人电话" prop="lfphone">
                    <el-input v-model="dataForm.lfphone" placeholder="请输入" clearable :style='{"width":"100%"}'>

                    </el-input>
                  </el-form-item>
                </el-col>
              </el-row>
            </el-col>
            <el-col :span="12">
              <el-row :gutter="15">
                <el-col :span="24">
                  <el-form-item label="本次接待负责人姓名" prop="jdperson">
                    <el-input v-model="dataForm.jdperson" placeholder="请输入" clearable :style='{"width":"100%"}'>

                    </el-input>
                  </el-form-item>
                </el-col>
              </el-row>
            </el-col>
            <el-col :span="12">
              <el-row :gutter="15">
                <el-col :span="24">
                  <el-form-item label="本地接待负责人电话" prop="jdphone">
                    <el-input v-model="dataForm.jdphone" placeholder="请输入" clearable :style='{"width":"100%"}'>

                    </el-input>
                  </el-form-item>
                </el-col>
              </el-row>
            </el-col>
            <el-col :span="12">
              <el-row :gutter="15">
                <el-col :span="24">
                  <el-form-item label="接待开始时间" prop="jdstarttime">
                    <el-date-picker v-model="dataForm.jdstarttime" placeholder="请选择" clearable :style='{"width":"100%"}'
                      type="date" format="yyyy-MM-dd" value-format="timestamp">

                    </el-date-picker>
                  </el-form-item>
                </el-col>
              </el-row>
            </el-col>
            <el-col :span="12">
              <el-row :gutter="15">
                <el-col :span="24">
                  <el-form-item label="接待结束时间" prop="jdendtime">
                    <el-date-picker v-model="dataForm.jdendtime" placeholder="请选择" clearable :style='{"width":"100%"}'
                      type="date" format="yyyy-MM-dd" value-format="timestamp">

                    </el-date-picker>
                  </el-form-item>
                </el-col>
              </el-row>
            </el-col>
            <el-col :span="24">
              <el-row :gutter="15">
                <el-col :span="24">
                  <el-form-item label="来访目的" prop="lftarger">
                    <el-input v-model="dataForm.lftarger" placeholder="请输入" :style='{"width":"100%"}' true
                      type="textarea" :autosize='{"minRows":4,"maxRows":4}'>

                    </el-input>
                  </el-form-item>
                </el-col>
              </el-row>
            </el-col>
            <el-col :span="24">
              <el-row :gutter="15">
                <el-col :span="24">
                  <el-form-item label="备注" prop="lfrmk">
                    <el-input v-model="dataForm.lfrmk" placeholder="请输入" :style='{"width":"100%"}' true type="textarea"
                      :autosize='{"minRows":4,"maxRows":4}'>

                    </el-input>
                  </el-form-item>
                </el-col>
              </el-row>
            </el-col>
          </template>
        </el-form>
      </el-row>
    </div>
  </div>
</template>
<script>
  import request from '@/utils/request'
  import {
    getDictionaryDataSelector
  } from '@/api/systemData/dictionary'
  import {
    getDataInterfaceRes
  } from '@/api/systemData/dataInterface'

  export default {
    components: {},
    props: [],
    data() {
      return {
        loading: false,
        dataForm: {
          companyid: '',
          visitnum: '',
          lfcompant: '',
          lfreason: '',
          lfperson: '',
          lfphone: '',
          jdperson: '',
          jdphone: '',
          jdstarttime: '',
          jdendtime: '',
          lftarger: '',
          lfrmk: '',
        },

        rules: {},
      }
    },
    computed: {},
    watch: {},
    created() {},
    mounted() {},
    methods: {
      goBack() {
        this.$emit('refresh')
      },
      init(companyid,receivebaseid) {
        this.dataForm.companyid = companyid;
        this.getDetail(receivebaseid)
      },
      getDetail(receivebaseid) {
        request({
          url: `/api/example/BusReceiveBaseInfo/${receivebaseid}`,
          method: 'get',
        }).then((res) => {
          console.log(res)
          if(res.data){
            this.dataForm=res.data
          }          
        })            
      },
      // 表单提交
      dataFormSubmit() {
        this.$refs['elForm'].validate((valid) => {
          if (valid) {
            var _data = this.dataList()
            request({
              url: `/api/example/BusReceiveBaseInfo`,
              method: 'post',
              data: _data
            }).then((res) => {
              this.$message({
                message: res.msg,
                type: 'success',
                duration: 1000,
                onClose: () => {
                  this.resetForm()
                  this.$emit('refresh',true)
                }
              })
            })
          }
        })
      },
      resetForm() {
        this.$refs['elForm'].resetFields()
        this.init()
      },
      dataList() {
        var _data = JSON.parse(JSON.stringify(this.dataForm));
        return _data;
      },
      dataInfo(dataAll) {
        let _dataAll = dataAll
        this.dataForm = _dataAll
      },
    },
  }

</script>
